package qianfeng.com.meijiadaka.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;

import org.xutils.image.ImageOptions;
import org.xutils.x;

import java.util.List;

import qianfeng.com.meijiadaka.R;
import qianfeng.com.meijiadaka.bean.FindBean;


/**
 * Created by yanshihao on 2017/2/9.
 */

public class OtherAdapter  extends RecyclerView.Adapter<OtherAdapter.ViewHolder>{
    private Context mContext;
    private List<FindBean.ResultBean> mList;

    public OtherAdapter(Context context, List<FindBean.ResultBean> list) {
        mContext = context;
        mList = list;
    }

    @Override
    public OtherAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(mContext).inflate(R.layout.home_putong,parent,false);
        OtherAdapter.ViewHolder viewHolder=new OtherAdapter.ViewHolder(view);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(mContext,"点击了普通", Toast.LENGTH_SHORT).show();
            }
        });
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.tv.setText(mList.get(position).getNickname());
        ImageOptions options=new ImageOptions.Builder().setCircular(true).
                setLoadingDrawableId(R.mipmap.ic_launcher).build();
        x.image().bind(holder.iv2,mList.get(position).getAvatar(),options);
        Glide.with(mContext).load(mList.get(position).getPictureUrl()).into(holder.iv1);
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        ImageView iv1,iv2;
        TextView tv;
        public ViewHolder(View itemView) {
            super(itemView);
            iv1= (ImageView) itemView.findViewById(R.id.home_putong_iv1);
            iv2= (ImageView) itemView.findViewById(R.id.home_putong_iv2);
            tv= (TextView) itemView.findViewById(R.id.home_putong_tv);
        }
    }
}
